<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.akolomiets.search</groupId>
    <artifactId>git-search-app</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>

  <name>Git Search Client</name>
  <artifactId>git-search-client</artifactId>

  <build>
    <plugins>
      <!-- clean the dist directory used by Angular -->
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <filesets>
            <fileset>
              <directory>dist</directory>
            </fileset>
          </filesets>
        </configuration>
      </plugin>

      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.11.2</version>

        <executions>
          <!-- Install node and npm -->
          <execution>
            <id>Install Node and NPM</id>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
            <configuration>
              <nodeVersion>v14.16.0</nodeVersion>
            </configuration>
          </execution>

          <!-- clean install -->
          <execution>
            <id>npm install</id>
            <goals>
              <goal>npm</goal>
            </goals>
          </execution>

          <!-- code validation -->
          <execution>
            <id>npm run lint</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <phase>test</phase>
            <configuration>
              <arguments>run lint</arguments>
            </configuration>
          </execution>

          <!-- build app -->
          <execution>
            <id>npm run build</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>run build --prod</arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>

    <resources>
      <resource>
        <directory>dist/git-search-client</directory>
        <targetPath>static</targetPath>
      </resource>
    </resources>
  </build>
</project>
